// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   StrictlyStore.java

package include.excel_import;

import include.excel_export.DataBaseInfo;
import include.excel_export.Masking;
import include.excel_import.helper.Information;
import include.nseer_db.nseer_db;
import java.util.Vector;

// Referenced classes of package include.excel_import:
//			XlsInfo

public class StrictlyStore
{

	private nseer_db db;
	private XlsInfo xlsInfo;
	private Masking xml;
	private DataBaseInfo dbinfo;
	private String fileName;
	private Vector informations;
	private String table;
	private String realTableName;
	private String message;

	public StrictlyStore(String table, String database, String configFile, String fileName)
	{
		db = null;
		xlsInfo = null;
		xml = null;
		dbinfo = null;
		this.fileName = null;
		informations = null;
		this.table = null;
		realTableName = null;
		message = null;
		db = new nseer_db(database);
		xlsInfo = new XlsInfo(fileName);
		xml = new Masking(configFile);
		dbinfo = new DataBaseInfo(database);
		informations = new Vector();
		this.table = table;
		realTableName = xml.getTableNameFormNick(table);
		dbinfo.setTable(realTableName);
	}

	public void setTable(String table)
	{
		this.table = table;
	}

	public void setInformation(Vector informations)
	{
		this.informations = informations;
	}

	public void setXlsInfo(XlsInfo xlsInfo)
	{
		this.xlsInfo = xlsInfo;
	}

	public void execute()
	{
		try
		{
			Vector columns = xlsInfo.getColumnsName(table);
			StringBuffer sql = new StringBuffer("insert into ");
			sql.append(realTableName);
			StringBuffer sql2 = new StringBuffer(" (");
			Vector temp = new Vector();
			Vector columnNames = new Vector();
			for (int i = 0; i < informations.size(); i++)
			{
				Information information = (Information)informations.elementAt(i);
				columnNames.addElement(information.getItem());
				sql2.append(xml.getColumnName(table, information.getColumn()));
				sql2.append(",");
			}

			sql2 = (new StringBuffer(sql2.substring(0, sql2.length() - 1))).append(" ) ");
			String sheetName = ((Information)informations.elementAt(0)).getSheet();
			sql.append(sql2).append("values (");
			for (int i = 1; i < xlsInfo.getRowCount(sheetName); i++)
			{
				Vector parts = xlsInfo.getRowValues(i, columnNames, sheetName);
				StringBuffer statement = (new StringBuffer("")).append(sql);
				for (int j = 0; j < parts.size(); j++)
					statement.append("'").append(parts.elementAt(j)).append("',");

				String last = (new StringBuilder(String.valueOf(statement.substring(0, statement.length() - 1)))).append(")").toString();
				db.executeUpdate(last);
				statement = null;
				last = null;
				parts = null;
			}

			sql = null;
			sql2 = null;
			break MISSING_BLOCK_LABEL_377;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		db.close();
		dbinfo.finalize();
		break MISSING_BLOCK_LABEL_391;
		Exception exception;
		exception;
		db.close();
		dbinfo.finalize();
		throw exception;
		db.close();
		dbinfo.finalize();
	}

	public String getMessage()
	{
		return message;
	}
}
